<?php
namespace app\common\model;
use think\Request;
/**
 * 商家用户模型
 */
class StoreUser extends BaseModel
{
    protected $name = 'store_user';
	
	/**
     * 获取列表
     */
    public function getList()
    {
         // 执行查询
        $list = $this->order('store_user_id','desc')
            ->paginate(15, false, [
                'query' => Request::instance()->request()
            ]);
        return $list;
    }

	/**
     * 商户信息
     */
    public static function detail($user_name)
    {
        return self::useGlobalScope(false)->where('user_name',$user_name)->find();
    }
	
	/**
     * 商户信息
     */
    public static function detailId($store_user_id)
    {
        return self::useGlobalScope(false)->where('store_user_id',$store_user_id)->find();
    }

    /**
     * 新增默认商家用户信息
     */
    public function insertDefault($wxapp_id,$user_name)
    {
        return $this->save([
            'user_name' => $user_name,
            'password' => yoshop_hash($user_name),
            'wxapp_id' => $wxapp_id,
        ]);
    }

}
